package com.hsped.exception_;

import org.junit.jupiter.api.Test;

import java.util.*;

/**
 * @author 王先锋
 * @version 1.0
 */
public class Solution {
    public static void main(String[] args) {
        ListNode l = new ListNode();
        for (int i = 0; i < 3; i++) {
            l.val = 2;
            l = l.next;
        }
        System.out.println(l);
    }

    @Test
    public ListNode ReverseList(ListNode head) {
        List list = new ArrayList();

        while (head != null) {
            list.add(head.val);
            head = head.next;
        }
        Collections.reverse(list);
        ListNode head1 = new ListNode();
        for (Object i : list) {
            head1.val = (int) i;
            head1 = head1.next;
        }
        return head1;
    }
}

class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }

    public ListNode() {

    }
}